.class public Lrexsee/multimedia/RexseeImageCapture;
.super Ljava/lang/Object;
.source "RexseeImageCapture.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field public static final EVENT_ONIMAGECAPTUREFINISHED:Ljava/lang/String; = "onImageCaptureFinished"

.field private static final INTERFACE_NAME:Ljava/lang/String; = "ImageCapture"


# instance fields
.field private final mArguments:Lrexsee/multimedia/ImageCaptureArguments;

.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private mCamera:Landroid/hardware/Camera;

.field private mSurfaceDialog:Lrexsee/multimedia/SurfaceDialog;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 2
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    const/4 v0, 0x0

    .line 35
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 31
    iput-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mSurfaceDialog:Lrexsee/multimedia/SurfaceDialog;

    .line 32
    iput-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mCamera:Landroid/hardware/Camera;

    .line 36
    iput-object p1, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    .line 37
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onImageCaptureFinished"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 38
    new-instance v0, Lrexsee/multimedia/ImageCaptureArguments;

    invoke-direct {v0}, Lrexsee/multimedia/ImageCaptureArguments;-><init>()V

    iput-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mArguments:Lrexsee/multimedia/ImageCaptureArguments;

    .line 39
    return-void
.end method

.method static synthetic access$0(Lrexsee/multimedia/RexseeImageCapture;)Lrexsee/core/browser/Browser;
    .locals 1

    .prologue
    .line 30
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    return-object v0
.end method

.method static synthetic access$1(Lrexsee/multimedia/RexseeImageCapture;Landroid/hardware/Camera;)V
    .locals 0

    .prologue
    .line 32
    iput-object p1, p0, Lrexsee/multimedia/RexseeImageCapture;->mCamera:Landroid/hardware/Camera;

    return-void
.end method

.method static synthetic access$2(Lrexsee/multimedia/RexseeImageCapture;)Lrexsee/multimedia/ImageCaptureArguments;
    .locals 1

    .prologue
    .line 33
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mArguments:Lrexsee/multimedia/ImageCaptureArguments;

    return-object v0
.end method

.method static synthetic access$3(Lrexsee/multimedia/RexseeImageCapture;)Landroid/hardware/Camera;
    .locals 1

    .prologue
    .line 32
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mCamera:Landroid/hardware/Camera;

    return-object v0
.end method

.method static synthetic access$4(Lrexsee/multimedia/RexseeImageCapture;)Lrexsee/multimedia/SurfaceDialog;
    .locals 1

    .prologue
    .line 31
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mSurfaceDialog:Lrexsee/multimedia/SurfaceDialog;

    return-object v0
.end method

.method static synthetic access$5(Lrexsee/multimedia/RexseeImageCapture;Lrexsee/multimedia/SurfaceDialog;)V
    .locals 0

    .prologue
    .line 31
    iput-object p1, p0, Lrexsee/multimedia/RexseeImageCapture;->mSurfaceDialog:Lrexsee/multimedia/SurfaceDialog;

    return-void
.end method


# virtual methods
.method public getArguments()Ljava/lang/String;
    .locals 1

    .prologue
    .line 182
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mArguments:Lrexsee/multimedia/ImageCaptureArguments;

    invoke-virtual {v0}, Lrexsee/multimedia/ImageCaptureArguments;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 21
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 17
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "ImageCapture"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 25
    new-instance v0, Lrexsee/multimedia/RexseeImageCapture;

    invoke-direct {v0, p1}, Lrexsee/multimedia/RexseeImageCapture;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public setArguments(Ljava/lang/String;)V
    .locals 1
    .param p1, "arguments"    # Ljava/lang/String;

    .prologue
    .line 185
    iget-object v0, p0, Lrexsee/multimedia/RexseeImageCapture;->mArguments:Lrexsee/multimedia/ImageCaptureArguments;

    invoke-virtual {v0, p1}, Lrexsee/multimedia/ImageCaptureArguments;->parseArguments(Ljava/lang/String;)Lrexsee/multimedia/ImageCaptureArguments;

    .line 186
    return-void
.end method

.method public start(Ljava/lang/String;)Z
    .locals 1
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    .line 43
    const/4 v0, 0x0

    invoke-virtual {p0, p1, v0}, Lrexsee/multimedia/RexseeImageCapture;->start(Ljava/lang/String;Z)Z

    move-result v0

    return v0
.end method

.method public start(Ljava/lang/String;Z)Z
    .locals 10
    .param p1, "path"    # Ljava/lang/String;
    .param p2, "autoFocus"    # Z

    .prologue
    const/4 v6, 0x0

    const/4 v9, 0x1

    const/4 v8, 0x0

    .line 46
    invoke-static {p1}, Lrexsee/core/utilities/Utilities;->prepareWriteFile(Ljava/lang/String;)Ljava/io/File;

    move-result-object v3

    .line 47
    .local v3, "file":Ljava/io/File;
    if-nez v3, :cond_1

    .line 48
    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    if-eqz v5, :cond_0

    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeImageCapture;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    const-string v7, "Invalid target file path."

    invoke-virtual {v5, v6, v7}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    :cond_0
    move v5, v8

    .line 176
    :goto_0
    return v5

    .line 51
    :cond_1
    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-static {v5}, Lrexsee/multimedia/RexseeCameraPreview;->getPreview(Lrexsee/core/browser/Browser;)Lrexsee/multimedia/RexseeCameraPreview;

    move-result-object v4

    .line 52
    .local v4, "preview":Lrexsee/multimedia/RexseeCameraPreview;
    if-eqz v4, :cond_3

    .line 53
    invoke-virtual {v4}, Lrexsee/multimedia/RexseeCameraPreview;->getCamera()Landroid/hardware/Camera;

    move-result-object v1

    .line 54
    .local v1, "camera":Landroid/hardware/Camera;
    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mArguments:Lrexsee/multimedia/ImageCaptureArguments;

    invoke-virtual {v5, v1}, Lrexsee/multimedia/ImageCaptureArguments;->setCamera(Landroid/hardware/Camera;)Landroid/hardware/Camera;

    .line 55
    if-eqz p2, :cond_2

    .line 56
    new-instance v5, Lrexsee/multimedia/RexseeImageCapture$1;

    invoke-direct {v5, p0, p1}, Lrexsee/multimedia/RexseeImageCapture$1;-><init>(Lrexsee/multimedia/RexseeImageCapture;Ljava/lang/String;)V

    invoke-virtual {v1, v5}, Landroid/hardware/Camera;->autoFocus(Landroid/hardware/Camera$AutoFocusCallback;)V

    :goto_1
    move v5, v9

    .line 87
    goto :goto_0

    .line 74
    :cond_2
    new-instance v5, Lrexsee/multimedia/RexseeImageCapture$2;

    invoke-direct {v5, p0, p1}, Lrexsee/multimedia/RexseeImageCapture$2;-><init>(Lrexsee/multimedia/RexseeImageCapture;Ljava/lang/String;)V

    invoke-virtual {v1, v6, v6, v5}, Landroid/hardware/Camera;->takePicture(Landroid/hardware/Camera$ShutterCallback;Landroid/hardware/Camera$PictureCallback;Landroid/hardware/Camera$PictureCallback;)V

    goto :goto_1

    .line 90
    .end local v1    # "camera":Landroid/hardware/Camera;
    :cond_3
    :try_start_0
    new-instance v0, Lrexsee/multimedia/RexseeImageCapture$3;

    invoke-direct {v0, p0, p2, p1}, Lrexsee/multimedia/RexseeImageCapture$3;-><init>(Lrexsee/multimedia/RexseeImageCapture;ZLjava/lang/String;)V

    .line 171
    .local v0, "callback":Landroid/view/SurfaceHolder$Callback;
    new-instance v5, Lrexsee/multimedia/SurfaceDialog;

    iget-object v6, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    const-string v7, "window-dim-amount:0;window-modeless:true;window-cancelable:false;width:1px;height:1px;border-width:0px;"

    invoke-direct {v5, v6, v7}, Lrexsee/multimedia/SurfaceDialog;-><init>(Lrexsee/core/browser/Browser;Ljava/lang/String;)V

    iput-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mSurfaceDialog:Lrexsee/multimedia/SurfaceDialog;

    .line 172
    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mSurfaceDialog:Lrexsee/multimedia/SurfaceDialog;

    invoke-virtual {v5, v0}, Lrexsee/multimedia/SurfaceDialog;->start(Landroid/view/SurfaceHolder$Callback;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move v5, v9

    .line 173
    goto :goto_0

    .line 174
    .end local v0    # "callback":Landroid/view/SurfaceHolder$Callback;
    :catch_0
    move-exception v5

    move-object v2, v5

    .line 175
    .local v2, "e":Ljava/lang/Exception;
    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    if-eqz v5, :cond_4

    iget-object v5, p0, Lrexsee/multimedia/RexseeImageCapture;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeImageCapture;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6, v2}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    :cond_4
    move v5, v8

    .line 176
    goto :goto_0
.end method
